package com.shopping.util;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.sql.*;


public class JDBCUtil {
	private static ComboPooledDataSource cpds = null;
	private static int a=0;
	private static int b=0;

	static {
		cpds = new ComboPooledDataSource("mysql");
	}

	public static Connection getConnection() {
		Connection connection = null;
		try {
			connection = cpds.getConnection();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return connection;
	}

	public static void close(Connection conn, PreparedStatement pstmt, ResultSet rs) {
		try {
			if (rs != null) {
				rs.close();
			}
			if (pstmt != null) {
				pstmt.close();
			}
			if (conn != null) {
				conn.close();

			}
		} catch (SQLException e) {
			e.printStackTrace();
		}


	}
}
